package com.openjaw.lsy.agent.business;

import com.openjaw.lsy.agent.core.logging.api.ILog;
import com.openjaw.lsy.agent.core.logging.api.LogManager;
import com.openjaw.lsy.agent.core.plugin.intercept.enhance.InstanceMethodsAroundInterceptor;
import com.openjaw.lsy.agent.core.plugin.intercept.enhance.MethodInterceptResult;
import java.lang.reflect.Method;

public class ControllerInterceptor implements InstanceMethodsAroundInterceptor {
    ILog logger = LogManager.getLogger(ControllerInterceptor.class);

    @Override
    public void beforeMethod(Object objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
        MethodInterceptResult result) throws Throwable {
        String name = allArguments[0].toString();
        logger.info("beforeMethod*****" + name);
        allArguments[0] = name + "bbz";
        logger.info("beforeMethod*****更新参数" + allArguments[0]);
    }

    @Override
    public Object afterMethod(Object objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
        Object ret) throws Throwable {
        System.out.println("afterMethod*****" + allArguments[0]);
        ret = allArguments[0];
        return ret;
    }

    @Override public void handleMethodException(Object objInst, Method method, Object[] allArguments,
        Class<?>[] argumentsTypes, Throwable t) {

    }
}
